package com.medusa.aps.business.modules.basic.model.input;

import cn.hutool.core.util.StrUtil;
import com.medusa.aps.business.model.enums.ManufacturingStrategy;
import com.medusa.aps.business.model.enums.ProductionType;
import com.medusa.aps.business.model.pagination.Page;
import com.medusa.aps.business.modules.basic.mp.entity.Material;
import com.medusa.aps.business.global.model.o.RangeDate;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.Set;

@Getter
@Setter
public class MaterialParam extends Page<Material> {

    /**
     * 物料编码
     */
    @Schema(description = "物料编码")
    private String materialCode;
    /**
     * 物料编码集合
     */
    @Schema(description = "物料编码集合")
    private List<String> materialCodes;
    /**
     * 物料名称
     */
    @Schema(description = "物料名称")
    private String materialName;

    /**
     * 生产类型
     */
    @Schema(description = "生产类型")
    private ProductionType productionType;

    /**
     * 制造策略
     */
    @Schema(description = "制造策略")
    private ManufacturingStrategy manufacturingStrategy;

    /**
     * 创建人
     */
    @Schema(description = "创建人")
    private String creator;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private RangeDate createTime;


    /**
     * 导出的物料id集合
     */
    @Schema(description = "导出的物料id集合")
    private Set<Long> ids;

    public void setMaterialCode(String materialCode) {
        if (StrUtil.isEmpty(materialCode) || !materialCode.contains(StrUtil.COMMA)) {
            this.materialCode = materialCode;
            return;
        }
        this.materialCodes = StrUtil.split(materialCode, StrUtil.COMMA);
    }


}
